package llm_server

import (
	"fmt"
	"xiaozhi/config"
)

type LLMServer interface {
	Init()
	Start()
	Stop()
	OnMessage(prompt string, systemPrompt string, history []config.Message)
}

type LLM struct {
	Text   string `json:"text"`
	Result chan string
}

func (llm *LLM) OnMessage(prompt string, systemPrompt string, history []config.Message) error {
	fmt.Println("LLM start")
	var message string
	var err error
	switch config.NewSysConfig().LLMType {
	case config.NewSysServerType().DouBao:
		message, err = llm.OnDouBaoMessage(prompt, systemPrompt, history)
		break
	case config.NewSysServerType().DeepSeek:
		message, err = llm.OnDeepSeekMessage(prompt, systemPrompt, history)
		break

	}
	if err != nil {
		fmt.Println("LLM error", err)
		return err
	}
	llm.Text = message
	fmt.Println("LLM end")
	return nil
}
